﻿<?php

defined('_JEXEC') or die('Restricted access');
?>
<div class="row-fluid">
	<div class="alert">
		<table>
			<tr>
				 <td>
					<?php if(!empty($this->data->member_id)):?>
					<span style='width:150px; padding-right: 30px;'>Member ID assigned</span><span style='padding-right: 30px;'><strong><?php echo $this->data->member_id ; ?></strong></span>
					<?php endif ; 
						if(!empty($this->data->l_name) || !empty($this->data->f_name)):
					?>
					<span style='width:150px; padding-right: 30px;'>Member Name</span><span><strong><?php echo $this->data->l_name.' '.$this->data->f_name ; ?></strong></span>
					<?php endif; ?>
				</td>
			 	
			 	<td align='right'><?php echo 'Current points balance is' ; ?><br/>
					Số điểm của User_id <?php echo $this->p_o_u->user_id; ?>
				tính đến <?php echo $this->p_o_u->month.'-'.$this->p_o_u->year;?> là:
				</td>
			 	<td width='14%' align='left'>
					<b style='color : #FF0000 ; padding-left: 20px; '><?php echo number_format($this->infotest->point, 0,'.',',');?>
					</b><br/>
					<b style='color : #FF0000 ; padding-left: 20px; '><?php echo number_format($this->p_o_u->point, 0,'.',',');?> => ( Định test )</b>
				</td>
			 	
				
			 	<td align='right' width='10%'>
			 		<?php if($this->user->authorise('wrd.profile.pointhistory.add', 'com_wrd')): ?>
					<a href="index.php?option=com_wrd&controller=exchange&task=add<?php if(!empty($this->data->member_id)){ echo '&vip_num='.$this->data->member_id ; } ?>">
						<img title="Add New" style="float: right;" src="<?php echo JURI::base() .'/components/com_wrd/assets/images/add_new.png'?>">
			 		</a>
					<?php endif; ?>
			 	</td>
			 </tr>
			 <tr><td colspan="4" align="right" style="padding-right: 212px;">Số điểm của User lấy từ bảng Profile: <b><?php echo number_format($this->data->p_o_u, 0,'.',','); ?></b></td></tr>
	 	</table>
 	</div>
 	<table class="table table-striped adminlist">
		 <tr style="background-color: #F0F0EE;">
		 	<th>Order</th>
			<th>Reference number</th>	
			<th>Create date</th>	
		 	<th>Outlet</th>
		 	<th>Type</th>			
		 	<th>Point</th>
		 	<th>Expired Date</th>
		 </tr>
		 <?php if(count($this->point) > 0): ?>
			 <?php 
				$count = 0;
				foreach ($this->point as $w => $item): 
				//echo '<pre>';print_r($item);
			?>
			 	<?php if($item->point): 
					$cls = 0;
				 	if($w%2) $cls = 1;
				?>
				 	<tr class="<?php echo "row$cls"; ?>">
				 		<td><?php $count++; echo $count; ?></td>
						<td>
						<?php 
							if(($item->redemption_id) != '') {
								echo "<a href='index.php?option=com_wrd&controller=profile&layout=updateredemption&id=".$this->data->id."&uid=".$this->p_o_u->user_id."&code=".$item->redemption_id."'>"; echo $item->redemption_id;echo "</a>";
							}
							else if(!empty($item->transaction)&&($item->type == 2)){
								echo $item->transaction; 
							}	
							else
							{ 
								echo empty($item->transaction)? 0 : "<a rel='' href='index.php?option=com_wrd&controller=atransaction&tid=".$item->transaction."&layout=form'>".$item->transaction."</a>" ; 
							}
						?>
						</td>	
						<td><?php  echo date("d-m-Y",strtotime($item->created_date));?></td>	
				 		<td>
				 		<?php 
				 			if($item->type == 2){
								echo $item->des;
							}
							else if($item->outletName != ''){
								echo $item->outletName;
							} 
							else if(($item->type == 9) && ($item->transaction == 0)){
								echo "WMCRewards - Start Point";
							}
							else if(($item->type == 0) &&($item->transaction == 0)){
								echo "WMCRewards";
							}
							else if(!empty($this->t_outlet[$item->transaction])){						
									echo $this->t_outlet[$item->transaction] ;
							} 
							else if (empty($this->t_outlet[$item->transaction]) && ($item->type == 9)) {
								echo "WMCRewards - Point Adjustment";
							} 
							else {
								if($item->type==1) echo $item->des;
								else echo "WMCRewards - Contact IT for this case";

							}
			 			?>
				 		</td>				
					 	<td>
						 	<?php 
						 		switch($item->type){
						 			case 0 : 
						 				if($item->transaction != 0){
											echo "Transaction" ;
										}
										else {
											echo "Start Point";
										}
						 				break;
					 				case 1 : 
										echo "Registration"	;	 				
						 				break;
						 			case 2 : 
						 				echo "Point Adjustment" ;
						 				break;
					 				case 3 : 
						 				echo "Banner click" ;
						 				break;
									case 9 : 
						 				echo "Redemption" ;
						 				break;	
						 		}	
						 	?>
					 	</td>			
					 	<td><?php 
								
							if(intval($item->point)<0){	
								echo "<font style='color: red;font-weight: bold;'>".$item->point."</font>"; 
							}
							else { echo $item->point; }
						
						?></td>
					 	<td>
					 		<?php if(strtotime($item->expire) < time() && $item->expire != '0000-00-00'):?>
					 			<font color="#800000"><?php echo $item->expire; ?></font>
					 		<?php else: ?>
					 			<font><?php echo $item->expire; ?></font>
					 		<?php endif;?>
					 	</td>
				 	</tr>
			 	<?php endif ; ?>
			 <?php endforeach; ?>
			
		 <?php endif; ?>
	</table>
	<input type="hidden" name="flag_add_point" value="<?php echo (int)$this->data->id; ?>" />
</div>
